﻿using B.S.DataBase.MyProject.Domain.Procurements;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure.Interface;
using MediatR;
using T.E.ERP.Read.API.Applicantions.Command.ProcurementsCommand;

namespace T.E.ERP.Read.API.Applicantions.CommandHandler.ProcurementsCommandCommand
{
    /// <summary>
    /// 业务类型查询全部
    /// </summary>
    public class DocumentCommandHander : IRequestHandler<DocumentCommand, APIResult<List<Document>>>
    {
        /// <summary>
        /// 业务分类表
        /// </summary>
        private readonly IBaseRepository<Document> repository;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="repository"></param>
        public DocumentCommandHander(IBaseRepository<Document> repository)
        {
            this.repository = repository;
        }
        /// <summary>
        /// 处理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<APIResult<List<Document>>> Handle(DocumentCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<Document>> result = new APIResult<List<Document>>(); 


            result.Code = APIEnum.查询成功;
            result.Msg = APIEnum.查询成功.ToString();


            var list = repository.GetAll().Result;

            result.data =list.ToList();

            return  Task.FromResult(result);
        }
    }
}
